<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>11.未知宽高的img如何在容器里水平垂直居中</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                border: 0;
                list-style: none;
            }
            .clearfix:before,
            .clearfix:after {
                display: table;
                content: '';
            }
            .clearfix:after {
                clear: both;
            }
            .clearfix {
                *zoom: 1;
            }
            .fl {
                float: left;
            }
            .fr {
                float: right;
            }
            .wrap {
                width: 500px;
                height: 500px;
                border: 5px solid #000;
                margin: 50px auto;
                display: table;
                position: relative;
                text-align: center;
                overflow: hidden;
            }
            .wrap span {
                display: table-cell;
                *position: absolute;
                left: 50%;
                top: 50%;
                vertical-align: middle;
            }
            .wrap img {
                *position: relative;
                left: -50%;
                top: -50%;
                vertical-align: middle;
            }
        </style>
    </head>
    <body>
        <div class="wrap">
            <span><img src="images/littleGirl.jpg" /></span>
        </div>
    </body>
</html>
